package com.spring.learn.springboot._01;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * 注解方式的spring调用方式
 */
public class BeanTest {
    public static void main(String[] args) {
//        AnnotationConfigApplicationContext context=new AnnotationConfigApplicationContext(Myconfig.class,CompomentDemo.class,RepositoryDemo.class);
        AnnotationConfigApplicationContext context=new AnnotationConfigApplicationContext("com.spring.learn.springboot._01");
//        AnnotationConfigApplicationContext context=new AnnotationConfigApplicationContext(Scan.class);
//        System.out.println(context.getBean("createBean02Copy"));
        System.out.println(context.getBeansOfType(BeanInitAndClose02.class));
        System.out.println(context.getBean(BeanInitAndClose02.class));

        //除了bean以外还有component和repository两个注解
        //同样的还有service等
        // componet 指组件
        // repository 一般用在数据库层
        // service则是业务层
        // controller 则是web层
        //不写名称 首字母给小写了
        System.out.println(context.getBeansOfType(CompomentDemo.class));
        System.out.println(context.getBeansOfType(RepositoryDemo.class));

        context.close();
    }
}
